"""
定义文件操作相关的工具类
"""
import time
import os


def get_screenshot_png():
    root = os.path.dirname(os.path.dirname(__file__))
    # print('root---',root)
    local_time = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time()))

    return os.path.join(root, 'screenshots', local_time + '.png')


def get_data_file_path(filename):
    """
    传入一个文件名称，传出文件的绝对路径
    :param filename:
    :return:
    """
    root_dir = os.path.dirname(os.path.dirname(__file__))
    filepath = os.path.join(root_dir, 'data', filename)
    if os.path.exists(filepath):
        return filepath
    else:
        raise Exception(f"文件{filename}不存在")


if __name__ == '__main__':
    print(get_data_file_path("login_data.json"))
